<link href="/Content/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="/Content/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<script src="/Content/js/plugins/iCheck/icheck.min.js"></script>
<script src="/Content/js/plugins/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript" src="http://cdn.staticfile.org/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
<script src="/Content/layer/layer.js"></script>
<div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                         组管理
					<span style="float:right"><a href="/index.php/Home/Index/addzu">添加</a></span>
                    </div>
						
                    <div class="ibox-content">
				
                    <button id="delete" class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="Move to trash"><i class="fa fa-trash-o"></i> </button>
				
                        <table class="table table-striped">
                            <thead>
					
                            <tr>
							 <th>#</th>
							 <th>ID</th>
							   <th>组名称</th>
							  
								<th>操作</th>
								
                            </tr>
                            </thead>
                            <tbody>
						<volist name="alist" id="vo">
							<tr>
					 <td><input type="checkbox"  value="{$vo['id']}"  class="i-checks" name="input[]"></td>
						<td>{$vo['id']}</td>
						<td>{$vo['zuname']}</td>	  
						
						<th><a href="/index.php/Home/Index/addzu?id={$vo['id']}">修改 
						
						
						</th>
						
						</tr>						
				    </volist>
					<tr>
						<td colspan="9">
						<div class="pagelist">{$page}</div>
						</td>
					</tr>
                            </tbody>
                        </table>

                    </div>
						
                </div>
            </div>
			
<script src="https://cdn.socket.io/socket.io-1.2.1.js"></script>	
<script>
var socket;
        $(document).ready(function(){
		
			initsocket();
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
			
			$("#delete").click(function(){
				 var i=0;
				 var ids="";
				 $('.i-checks').each(function(){
				 var check = this;
					
					 if(check.checked){
					   i=i+1;
					   ids=ids+$(this).val()+",";    
					 }
					
				 });
				
				 if(i==0){
						  swal({
								title: "请选择要删除的内容",
								text: ""
							});

				 }else{
					 swal({
						title: "确定要删除吗?",
						text: "",
						type: "warning",
						showCancelButton: true,
						confirmButtonColor: "#DD6B55",
						confirmButtonText: "是",
						closeOnConfirm: false
					}, function () {
						ids=ids.substring(0,ids.length-1);
						$.post("/index.php/Home/Index/delzu",{"ids": ids},function(data){
							if(data=="0"){
								swal("Deleted!", "已删除", "success");
								window.location.reload();//刷新当前页面.
							}else{
								swal("Deleted!", "系统异常", "success");
							}
						});
						
					});

				 
				 }
			});
			$("#selecturl").click(function(){
			
				 var id="";
				 $('.i-checks').each(function(){
					var check = this;
					 if(check.checked){
					   id=$(this).data("url");
					 }
					
				 });
				 
				 if(id==""){
						swal({
								title: "请选择摄像头",
								text: ""
							});
				 }else{
				
					layer.open({
					  type: 1,
					  skin: 'layui-layer-rim', //加上边框
					  area: ['420px', '240px'], //宽高
					  content: id
					});
				 }
			});
			$("#selectrtmp").click(function(){
				
				 var id="";
				 $('.i-checks').each(function(){
				 var check = this;
					
					 if(check.checked){
					  
					   id=$(this).data("rtmp");
					 }
					
				 });
				
				 if(id==""){
						  swal({
								title: "请选择摄像头",
								text: ""
							});

				 }else{
					
					layer.open({
					  type: 1,
					  skin: 'layui-layer-rim', //加上边框
					  area: ['420px', '240px'], //宽高
					  content: id
					});
				 
				 }
			});
			//设置热门
			$("#sethot").click(function(){
				 var i=0;
				 var ids="";
				 $('.i-checks').each(function(){
				 var check = this;
					
					 if(check.checked){
					   i=i+1;
					   ids=ids+$(this).val()+",";    
					 }
					
				 });
				
				 if(i==0){
						  swal({
								title: "请选择直播",
								text: ""
							});

				 }else{
					 swal({
						title: "确定要设置热门吗?",
						text: "",
						type: "warning",
						showCancelButton: true,
						confirmButtonColor: "#DD6B55",
						confirmButtonText: "是",
						closeOnConfirm: false
					}, function () {
						ids=ids.substring(0,ids.length-1);
						$.post("/index.php/Home/Index/sethot",{"ids": ids},function(data){
							if(data=="0"){
								swal("Deleted!", "设置成功", "success");
								window.location.reload();//刷新当前页面.
							}else{
								swal("Deleted!", "系统异常", "success");
							}
						});
						
					});

				 
				 }
			});
			//清楚热门
			$("#clearhot").click(function(){
				 var i=0;
				 var ids="";
				 $('.i-checks').each(function(){
				 var check = this;
					
					 if(check.checked){
					   i=i+1;
					   ids=ids+$(this).val()+",";    
					 }
					
				 });
				
				 if(i==0){
						  swal({
								title: "请选择直播",
								text: ""
							});

				 }else{
					 swal({
						title: "确定要清除热门吗?",
						text: "",
						type: "warning",
						showCancelButton: true,
						confirmButtonColor: "#DD6B55",
						confirmButtonText: "是",
						closeOnConfirm: false
					}, function () {
						ids=ids.substring(0,ids.length-1);
						$.post("/index.php/Home/Index/clearhot",{"ids": ids},function(data){
							if(data=="0"){
								swal("Deleted!", "已清除", "success");
								window.location.reload();//刷新当前页面.
							}else{
								swal("Deleted!", "系统异常", "success");
							}
						});
						
					});

				 
				 }
			});
			
			
			
        });
		
function initsocket(){
socket=io.connect('{$socket}');//与服务器进行连接		
}
function send(str,type){
	var json = {};
	if(type=="滚屏"){
		json.type="tongzhi";
	}else{
		json.type="tanping";
	}

	json.content= str;
	var str= JSON.stringify(json);
	socket.emit('broadcast',str);
	layer.msg("发送成功");
}
    </script>
